package zzl.com.fof;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * Created by EDZ on 2018/3/27.
 */
public class FofReducer extends Reducer<Text,LongWritable,Text,Text>{
    Text rval = new Text();
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
        int sum = 0;
        int flag =0;
        for(LongWritable i:values){
          sum += i.get();
          if(i.get()==0){
              flag =1;
              break;
          }
        }
        if(flag==0){
            rval.set(sum +" ");
            context.write(key,rval);
        }
    }
}
